<template>
	<view class="" style="width: 100vw;height: 100vh">
		<view class="content" :style="{'background':kbackgroundColor}" style="min-height: 100vh">
			<hx-navbar title="转赠记录" :returnHome="true" :back="true" :fixed="false" :color="knavTitleColor"
				barPlaceholder="hidden" transparent="auto" @clickleft="clickleft()"></hx-navbar>
			<view class="order_tab_list">
				<view class="order_tab" :class="{tab_on:current == id}" :style="current == id? [selStyle]:[tabNormaleStyle]"
				v-for="item,id in tab_list" :key="id"
				@tap="on_tab_click(id)">
					{{item.name}}
				</view>
			</view>
			<view class="container">
				<view class="compound_item" :style="{background:kcellBgColor}"
					@tap="see_detail(item.id)" v-for="item,id in list" :key="id">
					<image :src="item.image" class="compound_img" mode="aspectFit"></image>
					<view class="info_box">
						<view class="info_text" :style="{'color':knormalColor}">{{item.goods_name}}</view>
						<view class="marginY">
							<!--0我收到的，1我送出的 -->
							<view style="font-size: 31rpx;" :style="{'color':knormalColor}">
								{{item.name}}
							</view>
							<view :style="{'color':knormalColor}">
								<text class="black">商品编号: #{{item.tokenId}}</text>
							</view>
							<view :style="{'color':knormalColor}">
								<view class="black" v-if="current == 0">
									转赠者: {{item.nickname}}
								</view>
								<view class="black" v-else>
									接受者: {{item.giveNickname}}
								</view>
							</view>
							<view class="info_time" :style="{'color':knormalColor}">
								<text class="num">
									{{current == 0?'收到':'赠送'}}时间: {{item.getTime|filterTime}}
								</text>
							</view>
							<!-- <text v-if="current == 1">的赠品</text> -->
						</view>

					</view>
				</view>
				<view style="text-align: center;" v-if="list.length == 0">
					<image src="@/static/without.png" style="width:550rpx;margin: 10rpx auto " alt="" mode="widthFix">
					</image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selectColorSize: this.$store.state.selectColorSize, //字体选中颜色
				// 	'我转赠的',
				// '我收到的',
				//	0我收到的，1我送出的   1我收到的，0我送出的
				tab_list: [
					{
						id: 0,
						name: "我收到的"
					},{
						id: 1,
						name: "我转赠的"
					},

				],
				current: 0,
				list: [],
				page: 1,
				limit: 10,
				hasNextPage: true,
				type: 0,
			}
		},
		filters: {
			filterTime(val) {
				return uni.$u.timeFormat(parseInt(val), 'yyyy-mm-dd hh:MM')
			}
		},
		onLoad(options) {
			this.$nextTick(() => {
				if (options.status)
					this.current = parseInt(options.status);
				this.get_data_list()
			})
		},
		onPullDownRefresh() {
			setTimeout(function() {
				uni.stopPullDownRefresh()
			}, 500)
		},
		// onReachBottom() {

		// 	let data = {
		// 		type:this.current
		// 	}
		// this.list = [];
		// 	this.$api.getGiveRecord(data, res => {
		// 		if (res.status) {

		// 			this.list = this.list.concat(res.data);

		// 		}
		// 	})
		// },
		methods: {
			clickleft() {
				uni.switchTab({
					url: '/pages/user/user'
				})
				//uni.navigateBack(2)
			},
			on_tab_click: function(id) {
				this.list = [];
				this.current = id;
				console.log("id------",	this.current)
				this.get_data_list()
			},

			get_data_list: function() {
				this.list = [];
				//0我收到的，1我送出的
				console.log("0我收到的，1我送出的", this.current)
				let data = {
					// page: this.page,
					// limit: this.limit
					type: this.current
				}
				//	data.turn_type = this.current + 1
				this.$api.getGiveRecord(data, res => {

					if (res.status) {
						this.list = res.data;
						//	this.hasNextPage = res.data.length >= this.limit;
					}
				})
			},
			see_detail: function(id) {
				uni.navigateTo({
					url: 'compound_page?id=' + id
				})
			}
		}
	}
</script>


<style lang="scss" scoped>
	.black {
		font-size: 22rpx;
		opacity: 0.7;
	}

	.container {
		padding: 20rpx 40rpx;
	}
	.order_tab_list {
		position: relative;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx 180rpx;
		.order_tab {
			width: 119rpx;
			// height: 54rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			position: relative;
			z-index: 2;
			font-size: 28rpx;
			color: var(--tabNormalColor);
		}
		.tab_on {
			color: var(--selectColorSize);
		}
		.tab_on::after {
			display: block;
			clear: both;
			content: '';
			width: 90%;
			height: 4rpx;
			background: var(--selBcakborder);
			border-radius: 100rpx;
			position: absolute;
			left: 50%;
			bottom: -12rpx;
			transform: translateX(-50%);
		}
	}
	.compound_item {
		width: 100%;
		height: 250rpx;
		background-color: $bg-box;
		border-radius: 20rpx;
		padding: 15rpx;
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;

		.compound_img {
			width: 160rpx; //200rpx;
			height: 180rpx;
			display: block;
			border-radius: 20rpx;
			// border: 1px solid gainsboro;
		}

		.info_box {
			flex: 1;
			padding-left: 18rpx;

			.info_time {
				width: 100%;
				display: flex;
				align-items: center;
				font-size: 24rpx;
				color: #000;
				.num {
					font-size: 22rpx;
					opacity: 0.7;
				}
				.give_userHead {
					width: 36rpx;
					height: 36rpx;
					border-radius: 50%;
					margin: 0 10rpx;
				}
			}

			.info_text {
				font-size: 32rpx;
				color: #000;
			}

			.marginY {
				line-height: 1.7;
				margin: 20rpx 0 20rpx;
			}
		}
	}

	.num_box {
		display: flex;
		align-items: center;
		margin-top: 10rpx;

		.num_left {
			width: 70rpx;
			height: 40rpx;
			background: #F0E0BE;
			border: 1rpx solid #EEDCAA;
			border-radius: 2rpx 0 0 2rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 22rpx;
			color: #000;
			font-weight: 500;
			position: relative;
			z-index: 10;
		}

		.num_right {
			height: 40rpx;
			font-size: 22rpx;
			text-align: center;
			border-radius: 0px 2rpx 2rpx 0px;
			white-space: nowrap;
			opacity: 1;
			padding: 0 10rpx;
			color: #EEDCAA;
			border: 1rpx solid #EEDCAA;
			border-left: none;
		}
	}
</style>